package com.originalpoint.origin_server.empty;



import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;


@Data

@Schema(name = "userId" ,description = "用户ID")
public class Result<T> {


	 //状态码  0.代表成功  其它代表失败状态码
	@Schema(name = "userId" ,description = "状态码  0.代表成功  其它代表失败状态码")
	private Integer status;

	//提示信息
	@Schema(name = "userId" ,description = "提示信息")
	private String msg;


	//响应数据
	@Schema(name = "userId" ,description = "响应数据")
	private T data;

	//总记录数
	@Schema(name = "userId" ,description = "总记录数")
	private Long count;


	/**
	* 构建带分页的返回
	* @param data
	* @param count
	* @return
	*/
	public static Result buildSuccess(Object data,Long count){
		Result result=new Result();
		result.setStatus(0);
		result.setMsg("操作成功");
		result.setData(data);
		result.setCount(count);
		return result;
	}

	/**
	* 构建普通数据的返回
	* @param data
	* @return
	*/
	public static Result buildSuccess(Object data){
		return buildSuccess(data,null);
	}



	/**
	* 构建不需要携带数据的成功
	* @return
	*/
	public static Result buildSuccess(){
		return buildSuccess(null);
	}


	/**
	* 构建失败的消息
	*@param code
	* @param msg
	* @return
	*/
	public static Result buildFail(Integer code,String msg){
		Result result=new Result();
		result.setStatus(code);
		result.setMsg(msg);
		return result;
	}


}